from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

url = r'http://172.16.36.121/upload/'

# # 2、方式2：指定 Chrome 浏览器位置：options 参数
chrome_location = r'D:\software\Win_x64_1135105_chrome-win\chrome-win\chrome.exe'
options = webdriver.ChromeOptions()
options.binary_location = chrome_location

driver = webdriver.Chrome(options=options)
driver.get(url)

# 方式1：取 title
title = driver.title
print(title)

# 方式2：取 text
text = driver.find_element(By.LINK_TEXT, '立即注册').text
print(text)

# 方式3：取 屬性值
href = driver.find_element(By.LINK_TEXT, '立即注册').get_attribute('href')
print(href)

driver.get(r'http://172.16.36.121/upload/forum.php?mod=viewthread&tid=2&extra=page%3D1')
text = driver.find_element(By.XPATH, '//*[@id="pid2"]/tbody/tr[1]/td[2]/div[1]/div[2]/div[2]/a[1]').text
print(text)
